#include "TriangleSetting.h"

TriangleSettingDialog::TriangleSettingDialog(Triangle* tri, QWidget* parent): QDialog(parent), tri(tri)
{
	ui.setupUi(this);
	ui.p1x->setValue(tri->p1.x());
	ui.p1y->setValue(tri->p1.y());
	ui.p1z->setValue(tri->p1.z());
	ui.p2x->setValue(tri->p2.x());
	ui.p2y->setValue(tri->p2.y());
	ui.p2z->setValue(tri->p2.z());
	ui.p3x->setValue(tri->p3.x());
	ui.p3y->setValue(tri->p3.y());
	ui.p3z->setValue(tri->p3.z());
	connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyChange()));
	connect(ui.matButton, SIGNAL(clicked()), this, SLOT(setMaterial()));
}

void TriangleSettingDialog::applyChange()
{
	tri->p1.setX(ui.p1x->value());
	tri->p1.setY(ui.p1y->value());
	tri->p1.setZ(ui.p1z->value());
	tri->p2.setX(ui.p2x->value());
	tri->p2.setY(ui.p2y->value());
	tri->p2.setZ(ui.p2z->value());
	tri->p3.setX(ui.p3x->value());
	tri->p3.setY(ui.p3y->value());
	tri->p3.setZ(ui.p3z->value());
}

void TriangleSettingDialog::setMaterial()
{
	ms = new MaterialSetting(tri, this);
	ms->exec();
	delete ms;
}